#ifndef __FIIPCLOUD_H
#define __FIIPCLOUD_H
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "./fiipCloudListeners.h"
#include "./fiipCloudVar.h"
#include "fiip-base/fiip.h"
#include "riselib/mempool.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
  cloudCmd_getId = 0x7011,
  cloudCmd_login = 0x7012,
  cloudCmd_heart = 0x7013,
  cloudCmd_bind = 0x7014,
  cloudCmd_unbind = 0x7015,
  cloudCmd_enterBinding = 0x7016,
  cloudCmd_setActualVar = 0x7021,
  cloudCmd_getActualVar = 0x7022,
  cloudCmd_subActualVar = 0x7023,
  cloudCmd_getActualAllVar = 0x7024,
  cloudCmd_subActualAllVar = 0x7025,
  cloudCmd_setTargetVar = 0x7029,
  cloudCmd_getTargetVar = 0x702A,
  cloudCmd_subTargetVar = 0x702B,
  cloudCmd_getTargetAllVar = 0x702C,
  cloudCmd_subTargetAllVar = 0x702D,
} CloudCmdEnum;

typedef enum {
  cloudEvent_getId = 0,
  cloudEvent_login,
  cloudEvent_heart,
  cloudEvent_bind,
  cloudEvent_unbind,
  cloudEvent_enterBinding,
  cloudEvent_beBound,
  cloudEvent_beUnbound,
  cloudEvent_subActualVar,
  cloudEvent_getActualAllVar,
  cloudEvent_subActualAllVar,
  cloudEvent_subTargetVar,
  cloudEvent_getTargetAllVar,
  cloudEvent_subTargetAllVar,
  CloudEvent_error,
  cloudEventNum,  // 记录元素个数
} CloudEventEnum;

extern FormatStruct* fiipCloud_txd;

void fiipCloud_init(uint8_t* id, uint8_t* key);
void fiipCloud_on(CloudEventEnum event, void* fun);
void* fiipCloud_getEmitter(CloudEventEnum event);
void fiipCloud_getId(uint8_t* typeId, uint8_t* typeKey);
void fiipCloud_login(void);
void fiipCloud_heart(void);
void fiipCloud_bind(uint8_t* typeId, uint8_t* code);
void fiipCloud_unbind(uint8_t* id);
void fiipCloud_enterBinding(uint8_t* code);
void fiipCloud_setActualVar(uint8_t* id,
                            uint8_t* key,
                            uint8_t* kVal,
                            uint8_t kLen,
                            uint8_t* vVal,
                            uint8_t vLen);
void fiipCloud_getActualVar(uint8_t* id,
                            uint8_t* key,
                            uint8_t* kVal,
                            uint8_t kLen);
void fiipCloud_subActualVar(uint8_t* id,
                            uint8_t* key,
                            uint8_t* kVal,
                            uint8_t kLen);
void fiipCloud_getActualAllVar(uint8_t* id, uint8_t* key);
void fiipCloud_subActualAllVar(uint8_t* id, uint8_t* key);
void fiipCloud_setTargetVar(uint8_t* id,
                            uint8_t* key,
                            uint8_t* kVal,
                            uint8_t kLen,
                            uint8_t* vVal,
                            uint8_t vLen);
void fiipCloud_getTargetVar(uint8_t* id,
                            uint8_t* key,
                            uint8_t* kVal,
                            uint8_t kLen);
void fiipCloud_subTargetVar(uint8_t* id,
                            uint8_t* key,
                            uint8_t* kVal,
                            uint8_t kLen);
void fiipCloud_getTargetAllVar(uint8_t* id, uint8_t* key);
void fiipCloud_subTargetAllVar(uint8_t* id, uint8_t* key);

#ifdef __cplusplus
}
#endif
#endif  //__FIIPCLOUD_H
